In = input().split()
Int = 0
b = True
Words = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
def pro(Int, Int2):
    a = True
    for i in range(2, int(Int ** 0.5 + 1)):
        if Int % 2 != 0:
            if Int % i == 0:
                a = False
                break
        else:
            a = False
            break
    if a:
        print(Int)
        return Int, Int2
    a = True
    for i in range(2, int(Int2 ** 0.5 + 1)):
        if Int2 % 2 != 0:
            if Int2 % i == 0:
                a = False
                break
        else:
            a = False
            break
    if a:
        print(Int2)
        return Int, Int2
    Int -= 1
    Int2 += 1
    pro(Int, Int2)
if len(In) == 3:
    for i in range(len(In)):
        if In[i] in Words:
            for j in range(10):
                if In[i] == Words[j]:
                    Int += j * (10 ** (len(In) - 1) // (10 ** i))
        else:
            b = False
            print("Wrong input")
            break
    if b:
        Int2 = Int
        pro(Int, Int2)
else:
    print("Wrong input")
